package com.zhuhai.repository;

import com.zhuhai.entity.Pnr;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

/**
 *  pnr Dao
 *  @author zhuhai
 *  @version 1.0.0.0
 */
public interface PnrReposity extends JpaRepository<Pnr, Integer>, JpaSpecificationExecutor<Pnr> {
    /**
     * 根據ID獲取pnr信息.
     * @param id
     * @return Pnr
     */
    @EntityGraph(value="pnr.all",type=EntityGraph.EntityGraphType.FETCH)
    @Query(value = "select p from Pnr p where p.id =  ?1")
    Pnr getPnrById(final Integer id);
}
